<template>
    <div class="yContainerColumnCenter yMatch">
        <div id="div_top" class="yContainerRowCenter yMatch_w" style="padding: 10px 10px 0 10px;">
            <button class="layui-btn yWeight" @click="click_min">最小化</button>
            <button class="layui-btn yWeight" @click="click_max">最大化</button>
            <button class="layui-btn yWeight" @click="click_full">全屏</button>
            <button class="layui-btn yWeight" @click="click_close">关闭</button>
        </div>
        <div id="div_content" class="yContainerColumnCenter yWeight">
            <button class="layui-btn" @click="click_layui">{{btn_layui_content}}</button>
            <el-button @click="click_element">{{btn_element_content}}</el-button>
        </div>
    </div>
</template>

<script>
    import {mapMutations, mapState} from 'vuex'

    let $this, yFree, Global;

    export default {
        computed: mapState(['title']),
        methods: {
            ...mapMutations(["initTitle"]),
            click_layui: () => {
                yFree.yShowBuilder(Global.IFinal.builderTitle, ["确定"], (index) => {
                    if (index === 1) yFree.yNotification(Global.IFinal.toastTitle, () => yFree.yToast(Global.IFinal.toastTitle, 6));
                }, false, 6);
            },
            click_element: () => {
                $this.$alert(Global.IFinal.builderTitle, `${yFree.webName}提示`, {
                    showClose: false,
                    dangerouslyUseHTMLString: true,
                }).then(() => $this.$message({message: Global.IFinal.toastTitle}));
            },
            click_min: () => yFree.yIPCSend(Global.IFinal.IPC.win_min),
            click_max: () => yFree.yIPCSend(Global.IFinal.IPC.win_max),
            click_full: () => yFree.yIPCSend(Global.IFinal.IPC.win_full),
            click_close: () => yFree.yIPCSend(Global.IFinal.IPC.win_close),
        },
        data() {
            return {
                btn_layui_content: "",
                btn_element_content: "",
            }
        },
        beforeCreate() {
            $this = this;
            yFree = $this.yFree;
            Global = $this.Global;
        },
        created() {
            $this.initTitle(yFree.webName);
            yFree.ySetTitle($this.title);
            $this.btn_layui_content = "Click Me(layui)";
            $this.btn_element_content = "Click Me(element)";
            $this.click_layui();
        },
    };
</script>

<style scoped>
    #div_top button {
        background: orangered;
    }

    #div_content .layui-btn {
        margin-bottom: 50px;
    }
</style>
